<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    {load file='/static/css/bootstrap.css'}
    {load file='/static/css/all.css'}
    {load file='/static/css/style.css'}
    {load file='/static/js/jquery-3.4.1.min.js'}
    {load file='/static/js/popper.js'}
    <!--<script src="https://cdn.staticfile.net/popper.js/1.15.0/umd/popper.min.js"></script>-->
    {load file='/static/js/bootstrap.js'}
    {load file='/static/js/bootbox.js'}
    <style type="text/css">
        body{background-color: rgba(250, 250, 240, 0.7)}
        .btn{
            width: 80px; /* 设置按钮宽度为 80 像素，可根据实际需求调整数值 */
            height: 30px; /* 设置按钮高度为 30 像素，可根据实际需求调整数值 */
            font-size: 12px; /* 同时可以适当调小按钮文字的字体大小，让整体更协调 */
            padding: 5px 10px;
        }
    </style>
</head>
<body>
<div class="container-furid" style="padding: 0px">
    <div class="row" style="padding-left: 20px">
        <form class="form-inline" action="" style="margin: 10px 0">

            <input id="key" type="text" class="form-control" name="key"  placeholder="姓名">&nbsp;&nbsp;

            <button type="submit" class="btn btn-primary" id="search"><span class="fa fa-search"></span>&nbsp;&nbsp;搜索</button>
        </form>
    </div>
    <table class="table table-hover">
        <tr><th>id</th><th>姓名</th><th>性别</th><th>年龄</th><th>看诊医生</th><th>病情</th><th>操作</th></tr>
        {volist name='data' id='v'}
        <tr><td>{$v.patientid}</td><td>{$v.patientname}</td><td>{$v.sex}</td><td>{$v.age}</td><td>{$v.doctorname}</td><td>{$v.patientstate}</td>
            <td><button class="btn btn-primary btn-edit" data-toggle='modal' data-target='#receiveModal' data-backdrop='static' onclick="edit({$v.num})"><span class="fa fa-edit"></span>查看</button></td></tr>
        {/volist}
    </table>
    {$data|raw}
</div>
<div class="modal" id="receiveModal">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <div class="modal-title">接诊结果</div>
                <button class="close" data-dismiss='modal'>&times;</button>
            </div>
            <div class="modal-body">
                <form action="" id="receiveForm">
                    <input type="hidden" id="num" name="num">
                    <input type="hidden" id="state" name="state" value="已看诊">
                    <div class="form-group">
                        <div class="row">
                            <div class="col-sm-6">
                                <label for="id">id：</label>
                                <input type="text" class="form-control" id="id" name="patientid" readonly>
                            </div>
                            <div class="col-sm-6">
                                <label for="name">姓名：</label>
                                <input type="text" class="form-control" id="name" name="patientname" readonly>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6">
                                <label for="sex">性别：</label>
                                <input type="text" class="form-control" id="sex" name="sex" readonly>
                            </div>
                            <div class="col-sm-6">
                                <label for="age">年龄：</label>
                                <input type="text" class="form-control" id="age" name="age" readonly>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6">
                                <label for="phone">phone：</label>
                                <input type="text" class="form-control" id="phone" maxlength="11" name="phone" readonly>
                            </div>
                            <div class="col-sm-6">
                                <label for="stime">看诊时间：</label>
                                <input type="text" class="form-control" id="stime" name="stime" value="{$stime}">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6">
                                <label for="patientstate">病情描述：</label>
                                <textarea class="form-control" rows="3" id="patientstate" name="patientstate" readonly></textarea>
                            </div>
                            <div class="col-sm-6">
                                <label for="result">看诊结果：</label>
                                <textarea class="form-control" rows="3" id="result" name="result" ></textarea>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="add()">保存</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script>
    function edit(id){
        $.get("/index.php/hospital/index/edit",{'id':id},function(res){
            $("#num").val(res.num);
            $("#id").val(res.patientid);
            $("#name").val(res.patientname);
            $("#age").val(res.age);
            $("#sex").val(res.sex);
            $("#patientstate").val(res.patientstate);
            $("#phone").val(res.phone);
        });
    }

    function add(){
        $.post("/index.php/hospital/index/update",$("#receiveForm").serialize(),function(res){
            if(res>0){
                bootbox.alert("已看诊",function(){
                    window.location.reload();
                    // window.location.href = '/index.php/hospital/subject/list';
                });
            }else{
                bootbox.alert("添加失败");
            }

        })

    }
</script>
